package enums;

import exception.IErrorCode;

/**
 * @author kehong
 * Created by on  2021-06-22 14:25
 */
public enum BaseErrorCode implements IErrorCode {
    SUCCESS("200", "操作成功"),
    INTERNAL_BUSSINESS_ERROR("201", "业务异常"),
    INTERNAL_SERVER_ERROR("500", "服务器内部错误"),
    INTER_REMOTE_ERROR("600", "服务内部调用错误"),
    SYSTEM_ERROR("900", "系统错误");

    private final String code;
    private final String message;

    private BaseErrorCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public String code() {
        return this.code;
    }

    @Override
    public String getMessage() {
        return this.message;
    }

    public static IErrorCode getByCode(String code) {
        BaseErrorCode[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            IErrorCode iErrorCode = var1[var3];
            if (code == iErrorCode.code()) {
                return iErrorCode;
            }
        }

        return INTERNAL_SERVER_ERROR;
    }
}
